package com.bc.bczbweb.controller;

import com.bc.bcapi.service.T_Menu_infoService;
import com.bc.bcapi.service.T_Role_infoService;
import com.bc.bcmodel.domain.T_Menu_infoModel;
import com.bc.commoncore.util.StringUtils;
import com.bc.commonentity.common.JsonResult;
import com.bc.bcapi.service.T_Authority_infoService;
import com.bc.bcmodel.domain.T_Authority_infoModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.math.BigInteger;
import java.util.List;
import java.util.stream.Collectors;

@Controller
@RequestMapping("t_authority_info")
public class T_Authority_infoController extends BaseController {
    @Autowired
    T_Authority_infoService t_Authority_infoService;

    @Autowired
    T_Menu_infoService t_Menu_infoService;

    @Autowired
    T_Role_infoService t_role_infoService;

    @RequestMapping("add")
    public ModelAndView add(String role_id) {
        String title = "角色权限管理-" + t_role_infoService.getRoleNameById(role_id);
        ModelAndView view = super.baseView(title, "t_authority_info/add");

        T_Menu_infoModel menuModel = new T_Menu_infoModel();
        menuModel.setStatus("1");
        List<T_Menu_infoModel> listMenu = t_Menu_infoService.getAllList(menuModel);

        T_Authority_infoModel modelAuth = new T_Authority_infoModel();
        modelAuth.setRole_id(role_id);
        modelAuth.setStatus("1");
        List<T_Authority_infoModel> listAuth = t_Authority_infoService.getAllList(modelAuth);
        StringBuilder sb = new StringBuilder();
//        sb.append();

        List<T_Menu_infoModel> listOne = listMenu.stream().filter(t -> t.getMenu_id().equals("")).collect(Collectors.toList());
        for (T_Menu_infoModel item :
                listOne) {

        }

        view.addObject("menu_data");
        view.addObject("role_id", role_id);
        view.addObject("title", title);
        return view;
    }
}